package me.zhengjie.tools.domain.vo

import cn.hutool.core.bean.BeanUtil
import cn.hutool.core.bean.copier.CopyOptions
import com.fasterxml.jackson.annotation.JsonTypeName
import me.zhengjie.common.utils.JacksonUtil
import jakarta.validation.constraints.NotBlank
import jakarta.validation.constraints.NotEmpty
import me.zhengjie.tools.domain.QiniuConfig
import org.apache.commons.lang3.builder.ToStringBuilder

/**
 * 发送邮件时，接收参数的类
 * @author 郑杰
 * @date 2018/09/28 12:02:14
 */

@JsonTypeName("EmailVo")
data class EmailVo (
    // 收件人，支持多个收件人，用逗号分隔
    var tos: @NotEmpty List<String>? = null,
    var subject: @NotBlank String? = null,
    var content: @NotBlank String? = null
){
    annotation class Update

    companion object {
        fun fromJson(json: String): EmailVo? {
            val obj= JacksonUtil.parseObject(json, EmailVo::class.java)!!
            return when(obj){
                is EmailVo -> obj
                else -> null
            }
        }
    }
    fun tojson():String? {
        return JacksonUtil.toJSONString(this)
    }

    fun copy(source: EmailVo?) {
        BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true))
    }
}